#!/bin/bash

install_packages() {
    # Debian/Ubuntu
    if [ -x "$(command -v apt)" ]; then
        sudo apt update && sudo apt upgrade -y
        sudo apt install -y build-essential uuid-dev acpica-tools nasm git libghc-x11-dev python3 python3-pip
        if [ $? -ne 0 ]; then
            echo "Error: Failed to install packages with apt"
            exit 1
        fi
    # RHEL/Fedora/CentOS/RockyLinux/AlmaLinux
    elif [ -x "$(command -v dnf)" ]; then
        sudo dnf update -y
        sudo dnf group install -y 'Development tools'
        sudo dnf install -y libuuid-devel acpica-tools nasm git ghc-X11-devel python3 python3-pip
        if [ $? -ne 0 ]; then
            echo "Error: Failed to install packages with dnf"
            exit 1
        fi
    else
        echo "Unsupported package manager. Please install dependencies manually."
        exit 1
    fi
}

install_packages
